/**
 * 
 */
package com.sri.business.login;

import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map;

import com.sri.db.dao.login.LoginDAO;
import com.sri.db.dao.login.LoginDAOServiceFactory;
import com.sri.formBeans.LoginForm;


/**
 * @author skodali
 * 
 */
public class LoginManager {
  private LoginManager() {
  }

  public static boolean login(LoginForm form) {
    System.out.println("login");
    boolean authenticated = false;
    LoginDAO loginDAO = LoginDAOServiceFactory.getLoginDAO();
    Map<String, String> map = new HashMap<String, String>();
    map.put("user", form.getUserName());
    map.put("password", form.getPassword());
    System.out.println("loginDAO");
    // returns true if the user has valid username & Password
    try {
      authenticated = loginDAO.checkUserCredentials(map);
    } catch (SQLException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
    return authenticated;
  }
}
